package com.photo.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.photo.system.common.ErrorCode;
import com.photo.system.exception.BusinessException;
import com.photo.system.mapper.AppointmentMapper;
import com.photo.system.model.dto.Appointment.AppointmentQueryRequest;
import com.photo.system.model.entity.Appointment;
import com.photo.system.model.vo.AppointmentVO;
import com.photo.system.service.AppointmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author xuwenhui
* @description 针对表【appointment(预约拍摄表)】的数据库操作Service实现
* @createDate 2024-12-15 18:33:39
*/
@Service
public class AppointmentServiceImpl extends ServiceImpl<AppointmentMapper, Appointment>
    implements AppointmentService {

    @Resource
    private AppointmentMapper appointmentMapper;

    @Override
    public Page<AppointmentVO> getQueryWrapperByAll(Page<AppointmentVO> pageParam, AppointmentQueryRequest appointmentQueryRequest) {
        // 自定义分页查询
        List<AppointmentVO> gradeVOList = appointmentMapper.getQueryWrapperByAll(pageParam, appointmentQueryRequest);
        if (gradeVOList == null) {
            throw new BusinessException(ErrorCode.OPERATION_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(gradeVOList);
        return pageParam;
    }

    @Override
    public Page<AppointmentVO> getQueryWrapperByMy(Page<AppointmentVO> pageParam, AppointmentQueryRequest appointmentQueryRequest, Long userId) {
        // 自定义分页查询
        List<AppointmentVO> gradeVOList = appointmentMapper.getQueryWrapperByMy(pageParam, appointmentQueryRequest,userId);
        if (gradeVOList == null) {
            throw new BusinessException(ErrorCode.OPERATION_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(gradeVOList);
        return pageParam;
    }
}




